package test

import com.alibaba.fastjson.JSON
import org.apache.http.client.methods.HttpGet
import org.apache.http.impl.client.HttpClients
import org.apache.http.util.EntityUtils

object PhoneAreaQuery {

  def main(args: Array[String]): Unit = {
    val phone = "13622228888"
    val httpClient = HttpClients.createDefault
    val httpGet = new HttpGet(s"http://cx.shouji.360.cn/phonearea.php?number=${phone}")
    val httpResponse = httpClient.execute(httpGet)
    val response = EntityUtils.toString(httpResponse.getEntity, "UTF-8")
    val data = JSON.parseObject(response).get("data").toString
    val city = JSON.parseObject(data).get("city").toString
    println(city)

    httpGet.releaseConnection()
    httpClient.close()
  }

}
